//
//  UIViewController + systemAlert.swift
//  Edaixi-iOS
//
//  Created by 刘树华 on 2017/11/30.
//  Copyright © 2017年 刘树华. All rights reserved.
//

import Foundation
import UIKit


extension UIViewController {
    
    func showSystemAlertController(title:String?,message:String?,action:[UIAlertAction]?)  {
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        if action != nil  {
            if action!.count > 0 {
                for ac in action! {
                    alert.addAction(ac)
                }
            }
          
        }
       self.present(alert, animated: true, completion: nil)
    }
    
    
    func showSystemAlertController(title:String?,message:String?,btn:String...,click:((UIAlertAction)->())?)  {
        var actionArr = [UIAlertAction]()
        
        for str in btn {
          actionArr.append(UIAlertAction(title: str, style: .default, handler: click))
        }
        if actionArr.count > 0 {
            showSystemAlertController(title: title, message: message, action: actionArr)
        }else{
             showSystemAlertController(title: title, message: message, action: nil)
        }
       
        
    }
    
    
    
}
